//
//  LessInforTop.m
//  fp
//
//  Created by xingshuai on 2020/11/13.
//

#import "LessInforTop.h"

@interface LessInforTop ()
// 背景图片
@property (nonatomic, strong) UIImageView *bg_img;
// 学校名称
@property (nonatomic, strong) UILabel *schoolName;
// 简介
@property (nonatomic, strong) UILabel *jianLabel;
// line
@property (nonatomic, strong) UILabel *line;
// 学校简介信息
@property (nonatomic, strong) UILabel *inforLabel;

@end

@implementation LessInforTop

-(UIImageView *)bg_img {
    if (!_bg_img) {
        _bg_img = [[UIImageView alloc]init];
        _bg_img.backgroundColor = [UIColor clearColor];
        _bg_img.image = [UIImage imageNamed:@"schoolInfoTop"];
        //_bg_img.contentMode = UIViewContentModeScaleAspectFill;
    }
    return _bg_img;
}

-(UILabel *)schoolName {
    if (!_schoolName) {
        _schoolName = [[UILabel alloc]init];
        _schoolName.text = @"上海外国语大学附属中心小学";
        _schoolName.textColor = [UIColor whiteColor];
        _schoolName.font = [UIFont pingFangSCWithWeight:FontWeightStyleMedium size:18];
        _schoolName.textAlignment = NSTextAlignmentCenter;
    }
    return _schoolName;
}

-(UILabel *)jianLabel {
    if (!_jianLabel) {
        _jianLabel = [[UILabel alloc]init];
        _jianLabel.text = @"简介";
        _jianLabel.textColor = [UIColor colorWithHexString:@"#4E75FF"];
        _jianLabel.font = [UIFont pingFangSCWithWeight:FontWeightStyleMedium size:18];
    }
    return _jianLabel;
}

-(UILabel *)line {
    if (!_line) {
        _line = [[UILabel alloc]init];
        _line.backgroundColor = [UIColor colorWithHexString:@"#4E75FF"];
        _line.layer.cornerRadius = 2;
        _line.layer.masksToBounds = YES;
    }
    return _line;
}

-(UILabel *)inforLabel {
    if (!_inforLabel) {
        _inforLabel = [[UILabel alloc]init];
        _inforLabel.numberOfLines = 4;
        _inforLabel.textColor = [UIColor colorWithHexString:@"#4E75FF"];
        _inforLabel.font = [UIFont pingFangSCWithWeight:FontWeightStyleRegular size:16];
        _inforLabel.text = @"同济大学历史悠久、声誉卓著，是中国最早的国立大学之一，是教育部直属并与上海市共建的全国重点大学。经过113年的发展，同济大学已经成为一所特色鲜明、在海内外有较大影响力的综合性、研究型、国际化大学，综合实力位居国内高校前列。学校始于1907年德国医生埃里希•宝隆在中德两国政府和社会各界支持下创办的同济德文医学堂。1912年与创办不久的同济德文工学堂合称同济德文医工学堂。1917年由华人接办，先后改称为同济医工学校和私立同济医工专门学校。1923年定名为同济大学，1927年成为国立大学。";
    }
    return _inforLabel;
}

-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor clearColor];
        
        [self addSubview:self.bg_img];
        [self addSubview:self.schoolName];
        [self addSubview:self.jianLabel];
        [self addSubview:self.line];
        [self addSubview:self.inforLabel];
    }
    return self;
}

-(void)layoutSubviews {
    [super layoutSubviews];
    
    [self.bg_img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.top.equalTo(self).offset(5);
        make.right.equalTo(self).offset(-15);
        make.bottom.equalTo(self).offset(-10);
    }];
    
    [self.schoolName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(self.bg_img.mas_top);
        make.size.mas_offset(CGSizeMake(300, 40));
    }];
    
    [self.jianLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bg_img.mas_left).offset(240);
        make.top.equalTo(self.schoolName.mas_bottom).offset(5);
    }];
    
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.jianLabel.mas_left);
        make.top.equalTo(self.jianLabel.mas_bottom).offset(3);
        make.size.mas_offset(CGSizeMake(18, 4));
    }];

    [self.inforLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.jianLabel.mas_left);
        make.top.equalTo(self.line.mas_bottom).offset(5);
        make.right.equalTo(self.bg_img.mas_right).offset(-60);
        make.bottom.equalTo(self.bg_img.mas_bottom).offset(-10);
    }];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
